#include "conf.h"

Conf::Conf(QObject *parent) :
    QObject(parent)
{

}

Conf::Conf(QString fileName, QObject *parent) :
    QObject(parent)
{
    settings = new QSettings(fileName,QSettings::IniFormat,this);
}

void Conf::reload() {

}

void Conf::save() {
    settings->sync();
}

QString Conf::getConf(QString group, QString key) {
    return settings->value(group+"/"+key).toString();
}

void Conf::setConf(QString group, QString key, QString value) {
    settings->setValue(group+"/"+key,QVariant(value));
}

QString Conf::get_plataforma() {
    return getConf("ambiente", "plataforma");
}

QString Conf::get_log() {
    return getConf("ambiente", "log");
}

QString Conf::get_id_departamento() {
    return getConf("ambiente", "id_departamento");
}

void Conf::set_id_departamento(QString id_departamento) {
    setConf("ambiente", "id_departamento", id_departamento);
}

QString Conf::get_model_balanca() {
    return getConf("balanca", "model");
}

QString Conf::get_port_balanca() {
    return getConf("balanca", "port");
}

QString Conf::get_baudrate_balanca() {
    return getConf("balanca", "baudrate");
}

void Conf::set_model_balanca(QString model) {
    setConf("balanca", "model", model);
}

void Conf::set_port_balanca(QString port) {
    setConf("balanca", "port", port);
}

void Conf::set_baudrate_balanca(QString baudrate) {
    setConf("balanca", "baudrate", baudrate);
}

QString Conf::get_primary_database_host() {
    return getConf("primary_database", "host");
}

QString Conf::get_primary_database_name() {
    return getConf("primary_database", "database");
}

QString Conf::get_primary_database_user() {
    return getConf("primary_database", "user");
}

QString Conf::get_primary_database_password() {
    return getConf("primary_database", "password");
}

void Conf::set_primary_database_host(QString host) {
    setConf("primary_database", "host", host);
}

void Conf::set_primary_database_name(QString database) {
    setConf("primary_database", "database", database);
}

void Conf::set_primary_database_user(QString user) {
    setConf("primary_database", "user", user);
}

void Conf::set_primary_database_password(QString password) {
    setConf("primary_database", "password", password);
}

QString Conf::get_secondary_database_host() {
    return getConf("secondary_database", "host");
}

QString Conf::get_secondary_database_name() {
    return getConf("secondary_database", "database");
}

QString Conf::get_secondary_database_user() {
    return getConf("secondary_database", "user");
}

QString Conf::get_secondary_database_password() {
    return getConf("secondary_database", "password");
}

void Conf::set_secondary_database_host(QString host) {
    setConf("secondary_database", "host", host);
}

void Conf::set_secondary_database_name(QString database) {
    setConf("secondary_database", "database", database);
}

void Conf::set_secondary_database_user(QString user) {
    setConf("secondary_database", "user", user);
}

void Conf::set_secondary_database_password(QString password) {
    setConf("secondary_database", "password", password);
}

QString Conf::get_admin_interface_user() {
    return getConf("admin_interface", "user");
}

QString Conf::get_admin_interface_password() {
    return getConf("admin_interface", "password");
}

QString Conf::get_interface_type() {
    return getConf("interface", "type");
}

